package per.dg.digital_klotski.views.base;

import android.os.Bundle;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import per.dg.digital_klotski.views.App;

public class BaseActivity extends AppCompatActivity {

    static int onResumeCount = 0;
    static int onStopCount = 0;
    boolean stopMusic = false;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    protected void onResume() {
        super.onResume();
        onResumeCount++;
        if(stopMusic ){
            onResumeCount = onResumeCount - onStopCount;
            onStopCount = 0;
            stopMusic = false;
        }
        ((App)getApplication()).startBgm();

    }

    @Override
    protected void onStop() {
        super.onStop();
        if(onResumeCount - onStopCount == 2){

        }else {
            ((App)getApplication()).stopBgm();
            stopMusic = true;

        }
        onStopCount++;
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
    }
}
